import { MatIconRegistry } from '@angular/material/icon';
import { DomSanitizer } from '@angular/platform-browser';

export const loadSvgResources = (ir: MatIconRegistry, ds: DomSanitizer) => {
  const imgDir = 'assets/img';

  const sidebardir = `${imgDir}/sidebar`;

  const dayDir = `${imgDir}/days`;

  const avatarDir = `${imgDir}/avatar`;

  const iconDir = `${imgDir}/icons`;

  ir.addSvgIconSetInNamespace(
    'avatars',
    ds.bypassSecurityTrustResourceUrl(`${avatarDir}/avatars.svg`)
  );

  ir.addSvgIcon(
    'unassigned',
    ds.bypassSecurityTrustResourceUrl(`${avatarDir}/unassigned.svg`)
  );

  ir.addSvgIcon(
    'day',
    ds.bypassSecurityTrustResourceUrl(`${sidebardir}/day.svg`)
  );

  ir.addSvgIcon(
    'month',
    ds.bypassSecurityTrustResourceUrl(`${sidebardir}/month.svg`)
  );

  ir.addSvgIcon(
    'project',
    ds.bypassSecurityTrustResourceUrl(`${sidebardir}/project.svg`)
  );

  ir.addSvgIcon(
    'projects',
    ds.bypassSecurityTrustResourceUrl(`${sidebardir}/projects.svg`)
  );

  ir.addSvgIcon(
    'week',
    ds.bypassSecurityTrustResourceUrl(`${sidebardir}/week.svg`)
  );

  ir.addSvgIcon(
    'move',
    ds.bypassSecurityTrustResourceUrl(`${iconDir}/move.svg`)
  );

  ir.addSvgIcon('add', ds.bypassSecurityTrustResourceUrl(`${iconDir}/add.svg`));

  ir.addSvgIcon(
    'delete',
    ds.bypassSecurityTrustResourceUrl(`${iconDir}/delete.svg`)
  );

  for (let i = 0; i < 32; i++) {
    ir.addSvgIcon(
      `day${i}`,
      ds.bypassSecurityTrustResourceUrl(`${dayDir}/day${i}.svg`)
    );
  }

  // const days = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];

  // days.forEach(d => ir.addSvgIcon(
  //   `day${d}`,
  //   ds.bypassSecurityTrustResourceUrl(`${dayDir}/day${d}.svg`)
  // );
};
